function fn_AcroMLEvents(Ancestor){
  class _AcroMLEvents extends Ancestor{
    constructor(){
      super();
      this.initialize();
    }
    initialize(){
      this.events={};
    }
    finalize(){
  
    }
    on(event,fn){
      let fns=this.events[event];
      if (!fns){
        fns=[];
        this.events[event]=fns;
      }
      let index=fns.indexOf(fn);
      if (index>=0) return false;
      fns.push(fn);
      return true;
    }
    off(event,fn){
      let fns=this.events[event];
      if (!fns) return false;
      let index=fns.indexOf(fn);
      if (index<0) return false;
      fns.splice(index,1);
      return true;
    }
    once(event,fn){
      let self=this;
      let fns=this.events[event];
      if (fns){
        for(let i=0;i<fns.length;i++){
          if (fns[i].fn===fn){
            return false;
          }
        }
      }
      let fn2=function(...args){
        fn(...args);
        self.off(event,fn2);
      }
      fn2.fn=fn;
      return this.on(event,fn2);
    }
    emit(event,...args){
      let fns=this.events[event];
      if (!fns) return false;
      if (fns.length<=0) return false;
      for (let i=0;i<fns.length;i++) fns[i](...args);
      return true;
    }
  }
  return _AcroMLEvents;
}
let AcroMLEvents=fn_AcroMLEvents(Object);
let acroMLEvents=new AcroMLEvents();

export {fn_AcroMLEvents,AcroMLEvents,acroMLEvents};
export default {fn_AcroMLEvents,AcroMLEvents,acroMLEvents};